package core.util;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class BeanUtils {

	@SuppressWarnings("unchecked")
	public static <T> T clone(T src) {
		ByteArrayOutputStream bos = new ByteArrayOutputStream();
		ObjectInputStream ois;
		try {
			ObjectOutputStream oos = new ObjectOutputStream(bos);
			oos.writeObject(src);
			ByteArrayInputStream bis = new ByteArrayInputStream(
					bos.toByteArray());
			ois = new ObjectInputStream(bis);
			return (T) ois.readObject();
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
}
